﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LineWatch_WinForm;
using System.Globalization;
using System.Configuration;

namespace Linewatch_SetupForm
{
    public partial class Setup : Form
    {
        public Setup()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string text = textBox1.Text;
            int outV;
            if (!int.TryParse(text, out outV))
            {
                MessageBox.Show("请输入数字");
                return;
            }
            SerialPortOperator sp = new SerialPortOperator("COM1", 9600);//ConfigurationManager.AppSettings["ComPort"], 9600);
            sp.WriteLine("@00WD5000" + outV.ToString("X").PadLeft(4, '0'));// ConfigurationManager.AppSettings["PlanNumDM"].PadLeft(4, '0') + outV.ToString("X").PadLeft(4, '0'));
            sp.ClosePort();
            MessageBox.Show("设置成功");
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string text = textBox2.Text;
            int outV;
            if (!int.TryParse(text, out outV))
            {
                MessageBox.Show("请输入数字");
                return;
            }
            SerialPortOperator sp = new SerialPortOperator("COM1", 9600);//ConfigurationManager.AppSettings["ComPort"], 9600);
            sp.WriteLine("@00WD5004" + outV.ToString("X").PadLeft(4, '0'));// ConfigurationManager.AppSettings["PlanNumDM"].PadLeft(4, '0') + outV.ToString("X").PadLeft(4, '0'));
            sp.ClosePort();
            MessageBox.Show("设置成功");
            this.Close();
        }
    }
}
